<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <input type="text" class="user">
    <br>
    <input type="text" class="pwd">
    <br>
    <button class="btn">登录</button>


    <script src="../js/tools_v2.js"></script>

    <script>

        $('.btn').onclick = function () {  
            const username = $('.user').value ;
            const password = $('.pwd').value ;

            if(username && password) {
                // 前端验证成功以后，再做ajax请求
                ajax({
                    type : 'get' ,
                    data : {
                        username ,
                        password
                    } ,
                    path : '../php/06login.php' ,
                    successCB : res => {
                        const {status , msg} = res ;
                        if(status) {
                            alert('登录成功');
                        } else {
                            alert(msg)
                        }
                    }
                })
            }
        }


    </script>
    
</body>
</html>